package resources;

import java.util.ArrayList;
import java.util.List;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.UriInfo;

import model.reservation.lectureRoom.Reservation;

import resources.reservations.ReservationLRScheduleRes;

import dao.Linker;
import dao.ReservationLRDAO;

@Path("/reservationlr")
public class ReservationLRRes 
{
	@Context
	UriInfo uriInfo;
	
	@Context
	Request request;
	
	@GET
	@Produces(MediaType.TEXT_XML)
	public List<Reservation> getDataBrowser() 
	{
		Linker.sort();
		
		List<Reservation> reservations = new ArrayList<Reservation>();
		reservations.addAll( ReservationLRDAO.getReservationCP().values() );
		return reservations; 
	}
	
	@GET
	@Produces(MediaType.APPLICATION_JSON)
	public List<Reservation> getDataBrowserJSON() 
	{
		return getDataBrowser(); 
	}
	
	@GET
	@Produces(MediaType.APPLICATION_XHTML_XML)
	public List<Reservation> getDataBrowserXHTML() 
	{
		return getDataBrowser(); 
	}
	
	@GET
	@Produces(MediaType.APPLICATION_XML)
	public List<Reservation> getDataBrowserXML() 
	{
		return getDataBrowser(); 
	}

	@Path("{schedule}")
	public ReservationLRScheduleRes getSubData(@PathParam("schedule") String id) 
	{
		return new ReservationLRScheduleRes(uriInfo, request, id);
	}
}